<?php
session_start();
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/database.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/functions.php');
require($_SERVER['DOCUMENT_ROOT'].'/resources/lib/class.admin.php');
$id=$_POST['id'];
$admin=new admin();
$posts=$admin->getBlogPosts($id); // if it's searchable then change the function...

?>	
  	<div style="float:left;width:850px;">
    
   		<h2 class="form-heading"><a href="/admin/resources/php/requests/actions/add-blog-post.php?page_id=<?php echo($id); ?>&url=<?php echo($url); ?>" id="add-new-content" ><img src="/admin/resources/images/add.png" /></a>&nbsp;Blog Posts (<?php echo($posts['num_results']); ?>)</h2>
    	<ul id="content-list">
		<?php
		foreach($posts['results'] as $row) {
			$_cid=(string)$row['_id'];
			?>
			<li class="content-node">
				<h3><a style="float:left;" class="delete-content" href="/admin/resources/php/requests/actions/delete-content.php?id=<?php echo($_cid); ?>&page_id=<?php echo($row['page_id']); ?>"><img src="/admin/resources/images/cancel.png"/></a>&nbsp;<?php echo($row['blog_title']); ?> (<?php echo(date("d/m/y G:i:s",$row['post_dates']['epoch'])); ?>)<a id="new-content-edit-button-<?php echo($_cid); ?>" style="float:right;" class="edit-blog-post" href="/admin/resources/php/requests/forms/edit-blog-post.php?id=<?php echo($_cid); ?>"><img src="/admin/resources/images/b_edit.png"/></a></h3>
				        <input type="hidden" value="<?php echo($_cid); ?>" class="node_id" />
        <input type="hidden" class="" id="node_order_<?php echo($_cid); ?>" value="<?php echo($content['order']); ?>" name="node_order[<?php echo($_cid); ?>]" />

			</li>
		<?php
        }
		unset($posts,$row);
		?>  
        </ul>  
</div>
<script>
$("#content-list").sortable({ handle: 'h3', helper: 'original' , items: 'li', cursor:'move', containment: '#content-list', placeholder: 'sort-placeholder'});

</script>